<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>截屏</title>
    <script type="text/javascript" src="html2canvas.js"></script>
    <!-- <script src="https://cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.js"></script> -->
</head>
<script type="text/javascript">
    function takeScreenshot() {
    console.log('test');
        html2canvas(document.getElementById('view'), {
            onrendered: function(canvas) {
                document.body.appendChild(canvas);
            },
        // width: 300,
        // height: 300
        });
    }
    //  截屏
</script>
<body>
    <div id="view" style="background:url(test.jpg) 50% no-repeat; width: 700px; height: 500px; ">
        <input type="button" value="截图" onclick="takeScreenshot()">
    </div>
</body>

</html>
